#include "RocketDude.h"
#include <cassert>

RocketDude *This;

void moveLeft(){
    Rect * pos = This->getPos();
    pos->posX-=10;
    This->setPos(pos);
}

void moveRight(){
    Rect * pos = This->getPos();
    pos->posX+=10;
    This->setPos(pos);
}

void moveUp(){
    Rect * pos = This->getPos();
    pos->posY-=10;
    This->setPos(pos);
}

void moveDown(){
    Rect * pos = This->getPos();
    pos->posY+=10;
    This->setPos(pos);

}

RocketDude::RocketDude(int pMaxHP, int pSpeed) :
    Character(pMaxHP, pSpeed) {
    This = this;
    PALETTE p;
    BITMAP *g =  load_tga("graphics/soldier.tga", p);
    assert(g != NULL);
    setGraphic(g);
    KeyboardHandler *keyboardHandler = CommonResource::getInstance()->getKeyboardHandler();
    keyboardHandler->registerKey(KEY_LEFT, moveLeft);
    keyboardHandler->registerKey(KEY_RIGHT, moveRight);
    keyboardHandler->registerKey(KEY_UP, moveUp);
    keyboardHandler->registerKey(KEY_DOWN, moveDown);
}

//void RocketDude::dispose(){return;}
